/**
 * 
 */
package com.yonder.agenda.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yonder.agenda.entity.Contact;
import com.yonder.agenda.repository.ContactRepository;
import com.yonder.agenda.repository.generic.EntityRepository;
import com.yonder.agenda.service.generic.AbstractEntityService;

/**
 * An implementation of {@link ContactService} interface.
 * 
 * @author CosminS
 * @since Jan 29, 2014
 */
@Service
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
@Transactional(readOnly = true, rollbackFor = Exception.class)
public class ContactService extends AbstractEntityService<Contact> {

	/**
	 * Injected {@link ContactRepository} repository.
	 */
	@Autowired
	private ContactRepository contactRepository;

	@Override
	protected EntityRepository<Contact> getRepository() {
		return contactRepository;
	}
	
	/**
	 * Search for a contact with the specified firs name and last name.
	 * 
	 * @param firstName
	 *            the first name.
	 * @param lastName
	 *            the last name.
	 * @return the specified contact.
	 */
	public Contact findByFirstNameAndLastName(String firstName, String lastName) {
		return contactRepository.findByFirstNameAndLastName(firstName, lastName);
	}
}